package com.yaodian100.ec.order.entity;

import java.math.BigDecimal;
import java.util.Collection;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

import com.yaodian100.core.common.entity.BaseEntity;

@Entity
@Table(name = "EC_SERVICE_ORDER_PRODUCT", uniqueConstraints = { @UniqueConstraint(columnNames = { "service_id",
		"prod_seq" }) })
public class ServiceOrderProduct extends BaseEntity {

	/**
	 *   
	 * 
	 */
	private static final long serialVersionUID = 6173275198766493791L;

	/**
	 * 主鍵值
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "seq_ec_service_orderprod")
	@SequenceGenerator(name = "seq_ec_service_orderprod", sequenceName = "seq_ec_service_orderprod")
	@Column(name = "service_prod_id")
	private Long serviceProdId;

	@Column(name = "order_prod_id", nullable = false)
	private Long orderProdId;

	/**
	 * 服務單號
	 */
	@Column(name = "service_id", length = 14, nullable = false)
	private String serviceId;

	/**
	 * 商品序號
	 */
	@Column(name = "prod_seq", nullable = false)
	private int prodSeq;

	/**
	 * 商品編號
	 */
	@Column(name = "prod_id", length = 10, nullable = false)
	private String prodId;

	/**
	 * 規格編號
	 */
	@Column(name = "prod_spec_id", length = 10, nullable = false)
	private String prodSpecId;

	/**
	 * 商品名稱
	 */
	@Column(name = "prod_name", length = 500, nullable = false)
	private String prodName;

	/**
	 * 商品規格名稱
	 */
	@Column(name = "prod_spec_name", length = 100, nullable = false)
	private String prodSpecName;

	/**
	 * 商品類別
	 */
	@Column(name = "prod_tp", length = 5, nullable = false)
	private String prodTp;

	/**
	 * 單位售價
	 */
	@Column(name = "unit_price", nullable = false, columnDefinition = "numeric(10,2)")
	private BigDecimal unitPrice;

	/**
	 * 金額 unitPrice * qty
	 */
	@Column(name = "amount", length = 15, nullable = false, columnDefinition = "numeric(10,2)")
	private BigDecimal amount;
	/**
	 * 實際取消coupon
	 */
	@Column(name = "coupon", length = 15, nullable = false, columnDefinition = "numeric(10,2)")
	private BigDecimal coupon;

	/**
	 * 取消coupon id
	 */
	@Column(name = "couponId", length = 40)
	private String couponId;

	/**
	 * 實際退款金額 amount - coupon
	 */
	@Column(name = "return_amount", length = 15, nullable = false, columnDefinition = "numeric(10,2)")
	private BigDecimal returnAmount;

	/**
	 * 數量
	 */
	@Column(name = "qty", nullable = false)
	private int qty;

	/**
	 * 目錄Tree
	 */
	@Column(name = "category_path", length = 80, nullable = false)
	private String categoryPath;

	/**
	 * 商品所屬pm
	 */
	@Column(name = "pm_id", length = 20, nullable = false)
	private String pmId;

	/**
	 * 商品所屬pm 群組
	 */
	@Column(name = "pm_group", length = 20, nullable = false)
	private String pmGroup;

	@Column(name = "order_id", length = 13, nullable = false)
	private String orderId;

	@Column(name = "logistic_tp", length = 5, nullable = false)
	private String logisticTp;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "logistic_send_dt")
	private Date logisticSendDt;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "logistic_final_dt")
	private Date logisticFinalDt;

	@Column(name = "logistic_st", length = 5, nullable = false)
	private String logisticSt;

	@Column(name = "logistic_no", length = 20)
	private String logisticNo;

	@Column(name = "logistic_company", length = 15)
	private String logisticCompany;

	@OneToMany(mappedBy = "serviceProdId")
	@LazyCollection(LazyCollectionOption.FALSE)
	@Cascade(value = { CascadeType.DELETE })
	private Collection<ServiceOrderDetail> serviceOrderDetail;
	@Column(name = "logistic_remark", length = 255)
	private String logisticRemark;

	@Column(name = "logistic_ref_num", length = 64)
	private String logisticRefNum;

	@Column(name = "DISCOUNT", columnDefinition = "numeric(10,2)")
	private BigDecimal discount = BigDecimal.ZERO;

	/**
	 * 退换货条件
	 */
	@Column(name = "RETURN_RULE", length = 5)
	private String returnRule = "07_15";

	/**
	 * @return the logisticRemark
	 */
	public String getLogisticRemark() {
		return logisticRemark;
	}

	/**
	 * @param logisticRemark the logisticRemark to set
	 */
	public void setLogisticRemark(String logisticRemark) {
		this.logisticRemark = logisticRemark;
	}

	/**
	 * @return the logisticRefNum
	 */
	public String getLogisticRefNum() {
		return logisticRefNum;
	}

	/**
	 * @param logisticRefNum the logisticRefNum to set
	 */
	public void setLogisticRefNum(String logisticRefNum) {
		this.logisticRefNum = logisticRefNum;
	}

	public Collection<ServiceOrderDetail> getServiceOrderDetail() {
		return serviceOrderDetail;
	}

	public void setServiceOrderDetail(Collection<ServiceOrderDetail> serviceOrderDetail) {
		this.serviceOrderDetail = serviceOrderDetail;
	}

	public Long getServiceProdId() {
		return serviceProdId;
	}

	public void setServiceProdId(Long serviceProdId) {
		this.serviceProdId = serviceProdId;
	}

	public String getServiceId() {
		return serviceId;
	}

	public void setServiceId(String serviceId) {
		this.serviceId = serviceId;
	}

	public int getProdSeq() {
		return prodSeq;
	}

	public void setProdSeq(int prodSeq) {
		this.prodSeq = prodSeq;
	}

	public String getProdId() {
		return prodId;
	}

	public void setProdId(String prodId) {
		this.prodId = prodId;
	}

	public String getProdSpecId() {
		return prodSpecId;
	}

	public void setProdSpecId(String prodSpecId) {
		this.prodSpecId = prodSpecId;
	}

	public String getProdName() {
		return prodName;
	}

	public void setProdName(String prodName) {
		this.prodName = prodName;
	}

	public String getProdSpecName() {
		return prodSpecName;
	}

	public void setProdSpecName(String prodSpecName) {
		this.prodSpecName = prodSpecName;
	}

	public String getProdTp() {
		return prodTp;
	}

	public void setProdTp(String prodTp) {
		this.prodTp = prodTp;
	}

	public BigDecimal getUnitPrice() {
		return unitPrice;
	}

	public void setUnitPrice(BigDecimal unitPrice) {
		this.unitPrice = unitPrice;
	}

	public BigDecimal getAmount() {
		return amount;
	}

	public void setAmount(BigDecimal amount) {
		this.amount = amount;
	}

	public BigDecimal getCoupon() {
		return coupon;
	}

	public void setCoupon(BigDecimal coupon) {
		this.coupon = coupon;
	}

	public BigDecimal getReturnAmount() {
		return returnAmount;
	}

	public void setReturnAmount(BigDecimal returnAmount) {
		this.returnAmount = returnAmount;
	}

	public int getQty() {
		return qty;
	}

	public void setQty(int qty) {
		this.qty = qty;
	}

	public String getCategoryPath() {
		return categoryPath;
	}

	public void setCategoryPath(String categoryPath) {
		this.categoryPath = categoryPath;
	}

	public String getPmId() {
		return pmId;
	}

	public void setPmId(String pmId) {
		this.pmId = pmId;
	}

	public String getPmGroup() {
		return pmGroup;
	}

	public void setPmGroup(String pmGroup) {
		this.pmGroup = pmGroup;
	}

	public String getOrderId() {
		return orderId;
	}

	public void setOrderId(String orderId) {
		this.orderId = orderId;
	}

	public Long getOrderProdId() {
		return orderProdId;
	}

	public void setOrderProdId(Long orderProdId) {
		this.orderProdId = orderProdId;
	}

	public String getLogisticTp() {
		return logisticTp;
	}

	public void setLogisticTp(String logisticTp) {
		this.logisticTp = logisticTp;
	}

	public Date getLogisticSendDt() {
		return logisticSendDt;
	}

	public void setLogisticSendDt(Date logisticSendDt) {
		this.logisticSendDt = logisticSendDt;
	}

	public Date getLogisticFinalDt() {
		return logisticFinalDt;
	}

	public void setLogisticFinalDt(Date logisticFinalDt) {
		this.logisticFinalDt = logisticFinalDt;
	}

	public String getLogisticSt() {
		return logisticSt;
	}

	public void setLogisticSt(String logisticSt) {
		this.logisticSt = logisticSt;
	}

	public String getLogisticNo() {
		return logisticNo;
	}

	public void setLogisticNo(String logisticNo) {
		this.logisticNo = logisticNo;
	}

	public String getLogisticCompany() {
		return logisticCompany;
	}

	public void setLogisticCompany(String logisticCompany) {
		this.logisticCompany = logisticCompany;
	}

	/**
	 * @return the discount
	 */
	public BigDecimal getDiscount() {
		return discount;
	}

	/**
	 * @param discount the discount to set
	 */
	public void setDiscount(BigDecimal discount) {
		this.discount = discount;
	}

	public String getCouponId() {
		return couponId;
	}

	public void setCouponId(String couponId) {
		this.couponId = couponId;
	}

	public String getReturnRule() {
		return returnRule;
	}

	public void setReturnRule(String returnRule) {
		this.returnRule = returnRule;
	}

}
